
function imgFocus(b, c) {
	var d = this;
	this.index = 1;
	this.imgSize = $(b + " .focusPic img").size();
	this.init = function () {
		$(b + " .focusPic a img").clone().appendTo(b + " .focusPreview");
		$(b + " .focusBtns").empty();
		for (i = this.imgSize, j = 0; i > 0; i--, j++) {
			$(b + " .focusBtns").append("<a>" + i + "</a>");
		}
		$(b + " .focusPic a").css("position", "absolute").eq(0).css("z-index", this.imgSize).css("position", "absolute");
		$(b + " .focusPic a:gt(0)").css("z-index", 1);
		this.setStatus(1);
		this.bindEvent();
	};
	this.bindEvent = function () {
		$(b + " .focusPreview img").hover(function () {
			$(this).addClass("active");
		}, function () {
			$(this).removeClass("active");
			$(b + " .focusPreview img").eq(d.index - 1).addClass("active");
		});
		$(b + " .focusPreview img").each(function (i) {
			$(this).click(function () {
				d.imgActive(i + 1);
			});
		});
		$(b + " .focusBtns a").hover(function () {
			$(this).addClass("active");
		}, function () {
			$(this).removeClass("active");
			$(b + " .focusBtns a").eq(d.imgSize - d.index).addClass("active");
		});
		$(b + " .focusBtns a").each(function (i) {
			$(this).click(function () {
				d.imgActive(d.imgSize - i);
			});
		});
	};
	this.setStatus = function (i) {
		$(b + " .focusPreview img").removeClass("active").eq(i - 1).addClass("active");
		$(b + " .focusBtns a").removeClass("active").eq(this.imgSize - i).addClass("active");
		$(b + " .focusTitles a").hide().eq(i - 1).show();
	};
	this.imgActive = function (i) {
		if (d.index != i) {
			var a = d.index;
			$(b + " .focusPic a").eq(i - 1).css("z-index", d.imgSize - 1);
			this.setStatus(i);
			d.index = i;
			$(b + " .focusPic a").eq(a - 1).fadeOut(500, function () {
				$(b + " .focusPic a").eq(i - 1).css("z-index", d.imgSize);
				$(b + " .focusPic a").eq(d.index - 1).siblings().css("z-index", 0).show();
			});
		}
	};
	this.next = function () {
		var a = d.index;
		if (a >= d.imgSize) {
			a = 1;
		} else {
			a++;
		}
		d.imgActive(a);
		setTimeout(d.next, c);
	};
	this.play = function () {
		this.init();
		setTimeout(this.next, c);
	};
}

